Repository navigation
[python] Enforce global limit for Torch streaming reads - #8977
Closed
XiaoHongbo-Hope wants to merge 1 commit into
Closed
XiaoHongbo-Hope wants to merge 1 commit into
XiaoHongbo-Hope wants to merge 1 commit into
Conversation
XiaoHongbo-Hope
marked this pull request as draft
August 1, 2026 08:21
Contributor
Author
|
Closing this draft because the Torch streaming global-limit issue predates and is independent of #8808. The cross-process quota implementation adds substantial complexity for a narrowly scoped behavior; we can revisit it separately if global LIMIT semantics are required for multi-worker Torch streaming reads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
TableRead.to_iteratorapplies its limit within one iterator. A streaming Torch dataset creates multiple iterators across DataLoader workers, split-prefetch threads, and shuffled split readers, so each iterator could consume the full limit independently. For example, two four-row splits withLIMIT 5returned eight rows with two DataLoader workers.This change adds a row quota shared by all worker processes and prefetch threads. A reader reserves quota before materializing its next row and returns unused reservations when an iterator is exhausted. The quota resets after all workers finish an iteration, including with persistent workers. Split assignment, worker concurrency, and prefetch concurrency remain enabled.
This bug predates and is independent of #8808, so the fix is submitted separately.
Tests
python3.11 -m pytest -q pypaimon/tests/torch_read_test.py(19 passed, 2 subtests passed)python3.11 -m flake8 --config=dev/cfg.ini pypaimon/read/datasource/torch_dataset.py pypaimon/tests/torch_read_test.pypy_compilefor the changed Python filesgit diff --checkThe regression coverage includes fork and spawn DataLoader workers, concurrent split prefetch, persistent-worker iteration reset, and shuffled streaming reads.